//
//  HFBaseTableViewController.swift
//  sinaMicroBlog
//
//  Created by mac on 15/11/8.
//  Copyright © 2015年 mac. All rights reserved.
//

import UIKit

class HFBaseTableViewController: UITableViewController,HFVisitorLoginViewDelegate {
    
    var userLogin = HFUserAccountViewModel().userLogin
    var visitorLoginView: HFVisitorLoginView?
    
    func visitorWillLogin() {
//        print("log in")
        let oAuthVc = HFQAuthViewController()
        let naVc = UINavigationController(rootViewController: oAuthVc)
        presentViewController(naVc, animated: true, completion: nil)
    }
    func visitorWillRegister() {
        print("register")
    }
    
    override func loadView() {
        userLogin ? super.loadView() : loadVisitorLoginView()
    }
    
    func loadVisitorLoginView() {
        visitorLoginView = HFVisitorLoginView()
        visitorLoginView?.visitorDelegate = self
        view = visitorLoginView
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorWillRegister")
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "visitorWillLogin")
    }

    override func viewDidLoad() {
        super.viewDidLoad()
    }

}
